<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="\static\layui-v2.7.2\layui\css\layui.css">
    <script src="\static\layui-v2.7.2\layui\layui.js"></script>
    <script src="\static\js\jquery2.1.3.min.js"></script>
    <style>
        body{
            /* background-image: linear-gradient(to right bottom, #031229, #082c54, #0d4783, #1165b6, #1284eb); */
            background-image: linear-gradient(to right top, #547cb9, #7381c4, #9286cc, #af8ad1, #cc8ed3);
        }
        .app{
            display:flex;
            flex-wrap:wrap;
            justify-content:space-around;
        }
        .circleImg{
        border-radius: 50%;
        width:100px;
        height:100px;
        margin: 20px auto;
        }
        .userinfo{
            border-radius: 15px;
            width: 18%;
            /* height: 232px; */
            border: 1px solid purple;
            text-align: center;
            /* background-image: url("/static/img/lv.jpg"); */
            background-image: linear-gradient(to right top, #d16ba5, #c777b9, #ba83ca, #aa8fd8, #9a9ae1, #8aa7ec, #79b3f4, #69bff8, #52cffe, #41dfff, #46eefa, #5ffbf1);
            float: left;
            margin: 25px 30px;
        }
    </style>
</head>
<body>
    <ul class="layui-nav"style="width: 100%;position: relative;height: 60px;">
        <li class="layui-nav-item" style="    position: absolute;    right: 135px;">
            <a href=""><img src="{{$userinfo->avatar}}" class="layui-nav-img">{{$userinfo->nickname}}</a>
            <dl class="layui-nav-child">
                <dd><a href="javascript:;">修改信息</a></dd>
                <dd><a href="javascript:;">安全管理</a></dd>
                <dd><a href="/login_out">退了</a></dd>
            </dl>
        </li>
    </ul>
    <div class="app">
        @foreach($userList as $v)
        <div class="userinfo">
            <img class="circleImg" src="{{$v->avatar}}"  />
            <h1 style="color: white;margin:15px;">{{$v->nickname}}</h1>
            <a href="javascript:;" onclick="chat('{{$v->id}}')" class="layui-btn" style="margin: 15px;background-color: #3d68af;">与他聊天</a>
        </div>
        @endforeach
    </div>
</body>
<script>
    function chat(id){
        var chatid = id;
        jQuery.ajax({
                type: "POST",
                url: "/join_chat",
                data: {
                    chatid:chatid
                },
                dataType: 'json',
                success: function (data) {
                    console.log(data)
                    if(data.code==200){
						window.location.href = "/chat/"+data.data.id;
					}else{
						alert(data.msg);
					}
                }
            });
    }
</script>
</html>